﻿cmake_minimum_required (VERSION 3.12)

project ("libs_cpp")

# 如果支持，请为 MSVC 编译器启用热重载。
if (POLICY CMP0141)
  cmake_policy(SET CMP0141 NEW)
  set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<IF:$<AND:$<C_COMPILER_ID:MSVC>,$<CXX_COMPILER_ID:MSVC>>,$<$<CONFIG:Debug,RelWithDebInfo>:EditAndContinue>,$<$<CONFIG:Debug,RelWithDebInfo>:ProgramDatabase>>")
endif()

set(CMAKE_USE_JNI false)

if (CMAKE_USE_JNI)
    find_package(JNI REQUIRED)
    set(JNI_INCLUDE_DIRS "E:/Java/openjdk-19.0.1/include" CACHE PATH "jni include")
    set(JNI_INCLUDE_DIRS "E:/Java/openjdk-19.0.1/include/win32" CACHE PATH "jni include")
endif ()

if (CMAKE_VERSION VERSION_GREATER 3.12)
   set(CMAKE_CXX_STANDARD 17)
   set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()

# 判断系统架构
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
    set(ARCH_TYPE "32")
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
    set(ARCH_TYPE "64")
else()
    message(WARNING "Unknown architecture: ${CMAKE_SIZEOF_VOID_P} bytes")
    set(ARCH_TYPE "Unknown")
endif()

if (ARCH_TYPE STREQUAL "64")
    if (MSVC)
        set(VLD_ROOT "E:/Visual Leak Detector")
        include_directories("${VLD_ROOT}/include")
        link_directories("${VLD_ROOT}/lib/Win64")
        link_libraries("${VLD_ROOT}/lib/Win64/vld.lib")
        #target_compile_definitions(${PROJECT_NAME} PRIVATE_CRTDBG_MAP_ALLOC)
    endif ()
endif ()

set(REFERENCE_DIR "${PROJECT_SOURCE_DIR}/../../Reference/CPP" CACHE INTERNAL "Path to Reference")

configure_file(
    "${CMAKE_SOURCE_DIR}/yzrilyzr_lang.natvis"
    "${CMAKE_BINARY_DIR}/bin/yzrilyzr_lang.natvis"
    COPYONLY)

file(COPY "${CMAKE_SOURCE_DIR}/fonts" DESTINATION  "${CMAKE_BINARY_DIR}/bin")

add_subdirectory ("yzrutil")
add_subdirectory ("SimpleDSP")
add_subdirectory ("FAQ")
add_subdirectory ("SimpleSynth")
add_subdirectory ("VMProtect")
add_subdirectory ("SimpleCanvas")
